package ru.urfc.portal.model.accounting;

import java.math.BigDecimal;
import java.util.Date;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

import ru.urfc.portal.ui.client.Constants;

@XmlRootElement(name = Constants.BALANCE_OPERATION)
public class UnifiedBalanceOperation implements BalanceOperation, Comparable<UnifiedBalanceOperation> {

	private BigDecimal amountWithSign;
	private Date date;
	private String name;
	private BigDecimal balance;
	
	public UnifiedBalanceOperation() {
	}

	public UnifiedBalanceOperation(BalanceOperation balanceOperation) {
		this(balanceOperation.getAmountWithSign(), balanceOperation.getDate(), 
				balanceOperation.getName());
	}

	public UnifiedBalanceOperation(BigDecimal amountWithSign, Date date, String name) {
		super();
		this.amountWithSign = amountWithSign;
		this.date = date;
		this.name = name;
	}

	@XmlElement
	@Override
	public BigDecimal getAmountWithSign() {
		return amountWithSign;
	}

	@XmlElement
	@Override
	public Date getDate() {
		return date;
	}

	@XmlElement
	@Override
	public String getName() {
		return name;
	}

	@Override
	public int compareTo(UnifiedBalanceOperation o) {
		return getDate().compareTo(o.getDate());
	}

	public BigDecimal getBalance() {
		return balance;
	}

	public void setBalance(BigDecimal balance) {
		this.balance = balance;
	}
	
}

